home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / comm2 / tatriv15.lha / rexx / tatrivia.trans
Text File  |  1995-10-15  |  13KB  |  430 lines

  1. /* $VER: TA-Trivia v1.5 (10/11/95) for TransAmiga by John Kratz
  2.    Fidonet 1:260/322.0, Internet jkratz@erc.cat.syr.edu
  3. */
  4.  
  5. options results
  6. signal on syntax
  7. signal on error
  8. signal on ioerr
  9.  
  10. /*************************************************************************/
  11.                         /* Sysop Configurable variables                  */
  12. oneright=0        /* Number of minutes to add for 1 right answers  */
  13. tworight=0        /* Number of minutes to add for 2 right answers  */
  14. threeright=0        /* Number of minutes to add for 3 right answers  */
  15. fourright=5        /* Number of minutes to add for 4 right answers  */
  16. fiveright=5        /* Number of minutes to add for 5 right answers  */
  17. sixright=5        /* Number of minutes to add for 6 right answers  */
  18. sevenright=5        /* Number of minutes to add for 7 right answers  */
  19. eightright=10        /* Number of minutes to add for 8 right answers  */
  20. nineright=20        /* Number of minutes to add for 9 right answers  */
  21. tenright=30        /* Number of minutes to add for 10 right answers */
  22.  
  23.                         /* Make sure this matches the # question files   */
  24. total=304        /* total number of question files available      */
  25. /*************************************************************************/
  26. ui=userinfo;tr=transmit;gc=getchar;ss=sendstring;si=systeminfo
  27. ui a;handle=result
  28. ui a;name=result
  29. ui o;access=result
  30. si m;timeallowed=(result-3)
  31. bbsidentify 'name';bbsname=result
  32. ver="TA Trivia v1.5"
  33. bbsidentify 'sysop';sysopname=result
  34. userinfo x ; ansi=result
  35. CSI    = '1b'x||'['
  36. CRLF    = '0d'x||'0a'x
  37. FF    = '0c'x
  38. if ansi='ON' then do
  39.     OFF = CSI'0m' ; BO = CSI'1m' ; UL = CSI'4m' ; IT = CSI'3m'
  40.     RED = CSI'31m' ; GREEN = CSI'32m' ; YELLOW = CSI'33m' ; BLUE = CSI'34m'
  41.     PURPLE = CSI'35m' ; CYAN = CSI'36m' ; WHITE = CSI'37m'
  42.        YELLOWBACK = CSI'43m'
  43. end
  44. else do
  45.     OFF = '' ; BO = '' ; UL = '' ; IT = ''
  46.     RED = '' ; GREEN = '' ; YELLOW = '' ; BLUE = ''
  47.     PURPLE = '' ; CYAN = '' ; WHITE = ''
  48.        YELLOWBACK = ''
  49. end    
  50. Highscores="BBS:Extras/TATRIVIA/Highscores.txt"
  51. c=0
  52. setnodelocation "Playing the Trivia game!"
  53. sysoplog name 'played the Trivia Game!'
  54. path='BBS:Extras/TaTrivia/'
  55. upath=path"users/"
  56. qpath=path"Questions/"
  57. quest="Questions"
  58. high= path"HighScores.txt"
  59. index=1
  60. check=1
  61. used.1=0
  62.  
  63. START:
  64. INST:
  65.     cls
  66.     ss GREEN
  67.         tr GREEN BO'TransAmiga Trivia Quizzer by' CYAN 'John Kratz.'GREEN
  68.         tr ''
  69.         tr 'The program will choose randomly among the' YELLOW total RED'trivia quizzes.'
  70.         tr ''
  71.         tr CYAN'Use the numbers 1,2,and to select your answer.'
  72.         tr ''
  73.         tr 'You may quit at any time by typing Q.'
  74.         tr ''        
  75.         address command 'WAIT 2 secs'
  76.  
  77. TITLESCREEN:
  78.     cls
  79.         tr ''
  80.     tr 'C________________________ ______________________'
  81.     tr '    /C//C/'
  82.     tr '   /C//C/'
  83.     tr '  /__________C________//________C________/'
  84.     tr 'C/    /C/    /'
  85.     tr 'C/    /C/    /'
  86.     tr 'C/    /C/    /'
  87.     tr 'C/    / ___C/    / ________   ___  __    ___   ___   ___'
  88.     tr 'C/    / /   |C/    / /   _   /  /  / |  |  /  /  /  /  /   |'
  89.     tr 'C/    / /    |C/    / /   //  /  /  /  |  | /  /  /  /  /    |'
  90.     tr 'C/    / /  |  |C/    / /   //  /  /  /   |  |/  /  /  /  /  |  |'
  91.     tr 'C/    / /  /|  |C/    / /C_/  /  /    |  |  /  /  /  /  /|  |'
  92.     tr '    /    / /  __   |C/    / /   /  |   /  /C|    /  /  /  /  __   |'
  93.     tr '   /    / /  /  |  |C/    / /   /|  |  /  /C|   /  /  /  /  /  |  |'
  94.     tr '  /____/ /__/   |__|C/____/ /___/ |__| /__/C|__/  /__/  /__/   |__|'
  95.     tr 'CBy John Kratz of Amiga Time BBS!'
  96.     tr 'CInternetjkratz@erc.cat.syr.edu'
  97.     tr 'CFidonet1:260/322.0'
  98.     tr 'CVersion'ver''
  99.     bufferflush
  100.         tr ''
  101. MAIN:
  102. tr 'C[V]iew High Scores   [P]lay TA Trivia' 
  103. if access > 200 then tr 'C[R]eset HighScores'
  104. tr 'C[Q]uit               [I]nstructions - How to Play'
  105. ss 'CYour Choice? ' ; gc ;ans=upper(ans) ; call GCCHECK
  106. if ans='P' then do
  107.      cls 
  108.      call STARTOVER
  109.      end
  110. if ans='V' then do
  111.      cls
  112.      call SHOWHIGHS
  113.      continue
  114.      call TITLESCREEN
  115.      end
  116. if ans='I' then do
  117.      cls 
  118.      sendfile 'BBS:Extras/TATrivia/TATRIVIA.DOC'
  119.      continue
  120.      end
  121. if access >= 200 & ans='R' then do
  122.      cls 
  123.      call RESET
  124.      end 
  125. if ans='T' then do
  126.      cls
  127.      systeminfo m ; timeleft = Result
  128.      systeminfo q ; daily = Result
  129.      userinfo u   ; onlinetime = Result
  130.      tr BO YELLOW'Your total online time per day is 'CYAN daily YELLOW' minutes!'
  131.      tr ' You have been online 'RED onlinetime YELLOW' minutes so far today!'
  132.      tr ' You have 'GREEN timeleft YELLOW' minutes left for today!'OFF
  133.      continue
  134.      call TITLESCREEN
  135.      end
  136. if ans='Q' then signal QUIT
  137. if ans='RESULT' then cls ; signal TITLESCREEN
  138. STARTOVER:
  139.     num=1;count=1
  140.     score=0
  141.     timenumb=0
  142.     listnum=random(1,total,66)
  143. GETQUESTIONS:
  144.     listnum=random(1,total,time('s'))
  145.     do i=1 to check
  146.     if used.i=listnum then signal GETQUESTIONS
  147.     end
  148.     used.index=listnum
  149.     check=index
  150.     index=index+1
  151.     if index=276 then do
  152.        do i=1 to check
  153.        used.i=0
  154.     end
  155.     index=1
  156.     check=1
  157.     end
  158.     if open('file',qpath||quest||listnum,'R') then do
  159.         do until EOF('file')
  160.             quest.num=readln('file')
  161.                 do i=1 to 4
  162.                 quest.num.i=readln('file')
  163.                 end
  164.             num=num+1
  165.         end
  166.             call close('file')
  167.     end
  168.     else do
  169.         tr "There has been a problem loading the question file"
  170.         exit 10
  171.     end
  172. SHOW:
  173.     cls
  174.     if count=num-1 then signal SHUTDOWN
  175.     tr ""
  176.     tr ""
  177.     ss ''YELLOWBACK BLUE bbsname"'s "RED"Trivia Quiz  "OFF 
  178.     tr " "
  179.     tr " "
  180.     if access >= 200 then do
  181.         ss ''BO GREEN"Question File number:"RED listnum
  182.     end
  183.     tr GREEN" Question number:"RED count
  184.     tr " "
  185.         tr CYAN quest.count YELLOW
  186.         tr ""
  187.             do i=1 to 4
  188.                 parse var quest.count.i isans 2 answer
  189.                 if isans="!" then theans=i
  190.                 if isans~="-" then transmit '' i'' answer
  191.             end
  192.     bufferflush
  193.     tr ''
  194.     tr RED" You have "CYAN score RED" right."
  195.         tr '' 
  196.     ss OFF PURPLE"Your Choice -> " CYAN ; gc
  197. ASKIT:
  198.     guess=upper(result)
  199.     tr CYAN guess
  200.     if guess="1" then signal CONTINUE
  201.     if guess="2" then signal CONTINUE
  202.     if guess="3" & if isans~="-" then signal CONTINUE
  203.     if guess="4" & if isans~="-" then signal CONTINUE
  204.     if guess="Q" then signal SHUTDOWN
  205.         if guess="RESULT" then SIGNAL MAIN2
  206.     if guess="q" then do
  207.         guess=upper(guess)
  208.                   signal SHUTDOWN
  209.     end
  210.         if guess~= "1" or guess ~= "2" or guess ~= "3" or guess ~= "4" or guess ~= "RESULT" then SIGNAL MAIN2
  211.     if guess="###PANIC" then signal exit 10
  212.     if guess="###panic" then signal exit 10
  213.     signal ASKIT
  214. MAIN2:
  215. Query PURPLE"FYour Choice -> "
  216. signal ASKIT
  217. CONTINUE:
  218.     if guess=theans then do
  219.         score=score+1
  220.         tr CYAN"  Correct."
  221.     end
  222.     else tr RED"  Sorry, that's wrong."
  223.         address command 'WAIT 1 secs'
  224.     count=count+1
  225.     if count > num then do
  226.         if guess=theans then do
  227.             tr CYAN"Correct."
  228.         end
  229.         else tr RED"Sorry, that's wrong."
  230.                 address command 'WAIT 1 secs'
  231.         signal SHUTDOWN
  232.     end
  233.     signal SHOW
  234. GCCHECK:
  235. ans=result
  236. if ans ='###PANIC' then do ; bufferflush ; exit 10 ; end
  237. return
  238. SHOWHIGHS:
  239. call READHIGH
  240. call SHOWFIVE
  241. return
  242. CHECKHI:
  243. call READHIGH
  244. x=0 ; gp=c ; if gp <= 0 then signal L288
  245. L276:
  246. x=x+1 ; if x > 10 then signal L288
  247. z=10 ; if zp.x.2=0 then signal L283
  248. if gp < zp.x.2 then signal L276
  249. L283:
  250. z1=z-1
  251. do y=1 to 3
  252. zp.z.y=zp.z1.y
  253. end y
  254. z=z-1 ; if z~ < x then signal L283
  255. zp.x.1=handle ; zp.x.2=gp ;zp.x.3=date() 
  256. tr "Congratulations! You Are One Of The Top 10 Players!"
  257. call open(f1,HIGHSCORES,'w')
  258. do x=1 to 10
  259.    do y=1 to 3
  260.    call writeln(f1,zp.x.y)
  261.    end y
  262. end x ; call close(f1)
  263. if gs=0 then cls ; call SHOWHIGHS
  264. bufferflush ; Address command 'Wait 2 secs'
  265. return
  266. L288:
  267. timenumb=0
  268. c=0
  269. tr CYAN center("Sorry, You did not make it into the "GREEN"Top Ten"CYAN". Try Again Next Time.",100)
  270. if count > 9 & score = 0 then signal ZERO
  271. SIGNAL ANOTHER
  272. return
  273. READHIGH:
  274. if ~exists(HighScores) then do
  275.    call open(f1,HighScores,'w')
  276.    do x=1 to 10
  277.    call writeln(f1,"Nobody Yet!") ; call writeln(f1,"0") ; call writeln(f1,"None Yet!!!")
  278.    end x ; call close(f1)
  279. end
  280. call open(f1,HighScores,'r')
  281. do x=1 to 10
  282.    do y=1 to 3
  283.       zp.x.y=readln(f1)
  284.    end y
  285. end x ; call close(f1)
  286. return
  287. ZERO:
  288.    newtime = ontime - 15
  289.    settime newtime
  290.    tr 'CÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»'
  291.    tr 'Cº       ÜÜÜÜÜÜÜ  ÜÜÜÜÜÜÜ  ÜÜÜÜÜÜÜ   ÜÜÜÜÜÜÜÜ         º'
  292.    tr 'Cº            /   Û        Û      Ý  Û      Û         º'
  293.    tr 'Cº           /    Û        Û      Ý  Û      Û         º'
  294.    tr 'Cº          /     ÛÜÜÜÜ    ÛÜÜÜÜÜÜÝ  Û      Û         º'
  295.    tr 'Cº         /      Û        Û   \     Û      Û         º'
  296.    tr 'Cº        /       Û        Û    \    Û      Û         º'
  297.    tr 'Cº       /        Û        Û     \   Û      Û         º'
  298.    tr 'Cº       ßßßßßßß  ßßßßßßß  ß      \  ßßßßßßßß         º'
  299.    tr 'Cº                                                    º'
  300.    tr 'Cº  ÜÜÜÜÜÜÜ   ÜÜÜÜÜ   ÜÜÜÜÜÜÜÜ   Ü      Ü   ÜÜÜÜÜÜÜÜ  º'
  301.    tr 'Cº  Û      Ý    Û     Û          Û      Û      Û      º'
  302.    tr 'Cº  Û      Ý    Û     Û          Û      Û      Û      º'
  303.    tr 'Cº  ÛÜÜÜÜÜÜÝ    Û     Û          ÛÜÜÜÜÜÜÛ      Û      º'
  304.    tr 'Cº  Û   \       Û     Û  ÜÜÜÜÜÜ  Û      Û      Û      º'
  305.    tr 'Cº  Û    \      Û     Û      Û   Û      Û      Û      º'
  306.    tr 'Cº  Û     \     Û     Û      Û   Û      Û      Û      º'
  307.    tr 'Cº  ß      \  ßßßßß   ßßßßßßßß   ß      ß      ß      º'
  308.    tr 'CÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹'
  309.    tr 'CºYou lose 15 minutes for not getting atleast 1 right!º'
  310.    tr 'CÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ'
  311.    address command 'WAIT 2 secs'
  312. return
  313. SHOWFIVE:
  314. tr ' ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»'
  315. tr ' º               TA Trivia High Scores!               º'
  316. tr ' º        Current Top Ten TA Trivia Champs:Cº'
  317. tr ' ºCº'
  318. tr ' º     NAMECTOTAL SCORE!CDATECº'
  319. tr ' ºCº'
  320. do x=1 to 10
  321. tr ' º'right('<'||x||'>',4)'  '||left(zp.x.1'                   ',20)''right(zp.x.2,2)' C'right(zp.x.3,11)'  º'
  322. end x
  323. tr ' ºCº'
  324. tr ' ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ'
  325. return
  326. SHUTDOWN:
  327. give=0
  328. si m ; ontime=result
  329. si q ; maxtime=result
  330. if count > 9 & score < 3 then SIGNAL L288
  331. if count > 9 & score > 3 then do
  332.     if score=4 then do
  333.         newtime = ontime + fourright
  334.         settime newtime
  335.         timenumb=fourright
  336.                 c=4
  337.     end
  338.     if score=5 then do
  339.                 newtime = ontime + fiveright
  340.         settime newtime
  341.         timenumb=fiveright
  342.                 c=5
  343.     end
  344.     if score=6 then do
  345.         newtime = ontime + sixright
  346.         settime newtime
  347.         timenumb=sixright
  348.                 c=6
  349.     end
  350.     if score=7 then do
  351.         newtime = ontime + sevenright
  352.         settime newtime
  353.         timenumb=sevenright
  354.                 c=7
  355.     end
  356.     if score=8 then do
  357.         newtime = ontime + eightright
  358.         settime newtime
  359.         timenumb=eightright
  360.                 c=8
  361.     end
  362.     if score=9 then do
  363.         newtime = ontime + nineright
  364.         settime newtime
  365.         timenumb=nineright
  366.                 c=9
  367.     end
  368.     if score=10 then do
  369.         newtime = ontime + tenright
  370.         settime newtime
  371.         timenumb=tenright
  372.                 c=10
  373.     end
  374. end
  375. if count > 9 & score > 3 then tr GREEN"You have been given "timenumb" extra minutes online for your "score" correct answers."
  376. if timenumb > 0 then do
  377.      si m ; ontime=result
  378.      si q ; maxtime=result
  379.      setnewtime = ontime + timenumb
  380.      tr 'Your OLD time remaining is:' ontime 'minutes'
  381.      tr 'Your New time remaining is:' setnewtime 'minutes'
  382.      if setnewtime > maxtime then do 
  383.         setnewtime = maxtime 
  384.         tr 'Sorry, you can only have 'maxtime 'minutes/day total'
  385.         end
  386.      continue
  387.      settime setnewtime
  388. end
  389.      give=1
  390.      SIGNAL CHECKHI
  391.      if give=0 then ss     
  392. ANOTHER:
  393.     ss YELLOW"Would you like to try another quiz? "CYAN"("GREEN"y"CYAN"/"RED"N"CYAN") "GREEN;gc;again=upper(result)
  394.     if again="Y" then do tr "Yes";    signal STARTOVER ; end
  395.     tr ""
  396.     tr GREEN"Returning you to "bbsname"."
  397.         cls
  398.     exit 10
  399. RESET:
  400. address command 'delete BBS:Extras/TATRIVIA/Highscores.txt'
  401. Call TITLESCREEN
  402. end
  403. QUIT:
  404. cls
  405. Tr 'Thank you' name 'for playing TA Trivia!'
  406. bufferflush ; exit 10
  407. IOERR:
  408.  tr ''
  409.  tr '*BOOM* Got an IO error. Please notify 'sysop'!'
  410.  SYSOPLOG '*BOOM* Got an IO error in TA Trivia.'
  411.  SYSOPLOG '---> Line: ' SIGL
  412.  BUFFERFLUSH
  413.  EXIT 10
  414. ERROR:
  415.  tr ''
  416.  tr '*BOOM* Got an error. Please notify 'sysop'!'
  417.  tr 'line: ' SIGL '  Severity: ' RC
  418.  SYSOPLOG '*BOOM* Got an error in TA Trivia..'
  419.  SYSOPLOG '---> Line: ' SIGL '  Severity: ' RC
  420.  BUFFERFLUSH
  421.  EXIT 10
  422. SYNTAX:
  423.  tr 'Error in 'ver'.  Line:  'SIGL
  424.  tr 'Error:  'RCALL errortext(RC)
  425.  tr 'Please notify 'sysopname'!'
  426.  tr 'Returning to 'BBSname'...'
  427.  SYSOPLOG 'Error in 'ver'.  Line:  'SIGL
  428.  SYSOPLOG 'Error:  'RCALL errortext(RC)
  429.  BUFFERFLUSH
  430.  EXIT 10